import {
  put,
  takeLatest,
  all,
  call,
} from 'redux-saga/effects'
import { user as userDuck } from 'ducks'
import getUser from 'graphql/getUser.graphql'
import { gqlQuery } from './utils'

function* getUserSaga() {
  const result = yield call(gqlQuery, getUser)
  yield put(userDuck.creators.actionReciveUser(result.user))
}

export default function* sagas() {
  yield all([
    takeLatest(userDuck.types.LOAD, getUserSaga),
  ])
}
